package com.llkj.contractmanagement.customview.pickerview.widget;

import android.content.Context;
import android.view.View;


import com.llkj.contractmanagement.R;
import com.llkj.contractmanagement.customview.pickerview.widget.adapters.ArrayWheelAdapter;

import java.util.ArrayList;


public class WheelType {
    private View view;
    private WheelView wv_option1;
    private ArrayList<String> mOptions1Items;
    private Context context;

    public View getView() {
        return view;
    }

    public void setView(View view) {
        this.view = view;
    }

    public WheelType(View view, Context context) {
        super();
        this.view = view;
        this.context = context;
        setView(view);
    }

    public void setPicker(ArrayList<String> optionsItems) {
        setPicker(optionsItems, false);
    }

    public void setPicker(ArrayList<String> options1Items, boolean linkage) {
        this.mOptions1Items = options1Items;
        // 选项1
        wv_option1 = (WheelView) view.findViewById(R.id.options1);
        wv_option1.setViewAdapter(new ArrayWheelAdapter(context, mOptions1Items));// 设置显示数据
        wv_option1.setCurrentItem(0);// 初始化时显示的数据
    }


    /**
     * 设置是否循环滚动
     *
     * @param cyclic
     */
    public void setCyclic(boolean cyclic) {
        wv_option1.setCyclic(cyclic);
    }

    /**
     * 返回当前选中的结果对应的位置数组 因为支持三级联动效果，分三个级别索引，0，1，2
     *
     * @return
     */
    public int[] getCurrentItems() {
        int[] currentItems = new int[3];
        currentItems[0] = wv_option1.getCurrentItem();
        return currentItems;
    }

    public void setCurrentItems(int option1) {
        wv_option1.setCurrentItem(option1);
    }

    /**
     * 设置可见的item数
     *
     * @param count
     */
    public void setVisibleItems(int count) {
        wv_option1.setVisibleItems(count);
    }
}
